#!/usr/bin/env bash
echo "更新代码...."
git pull

echo "开始编译...."
cargo build --release

BIN=./log_viewer_bin
if [ -d "$BIN" ]; then
    echo "备份原配置文件"
	cp -f "$BIN/config.toml" ./config_bak.toml
    echo "删除原目录...." 	
    rm -r -f "$BIN"
fi

mkdir "$BIN"

echo "拷贝程序和配置文件...."
cp -f ./target/release/log_viewer  "$BIN"
cp -f ./target/release/log_tool    "$BIN"
cp -r -f ./static  "$BIN"
cp -f ./log.toml  "$BIN"
cp -f ./config.toml  "$BIN"
cp -f ./cross_interface.txt "$BIN"

echo "程序已经拷贝到$BIN!"